/*
在对列进行离散化之后，使用挨个遍历的方法
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1005;

struct Line{
    LL x1,x2,y;
    int tag;
    Line(){}
    Line(LL x1_,LL x2_,LL y_,int tag_):x1{x1_},x2{x2_},y{y_},tag{tag_}{}
    bool operator<(const Line& line)const{
        return this->y<line.y;
    }
};
Line lines[2*N];
LL xs[2*N];
set<int> mys;
int n;

LL x1,x2,y11,y2;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld%lld%lld",&x1,&y11,&x2,&y2);
        lines[i] = Line(x1,x2,y11,-1);
        lines[i+n] = Line(x1,x2,y2,1);
        mys.insert(x1); mys.insert(x2);
    }
    sort(lines+1,lines+2*n+1);

    int u=1;
    for(auto p=mys.begin();p!=mys.end();p++) {
        xs[u] = *p;
        u++;
    }

    LL ans = 0;
    int counts[2*N];
    memset(counts,0,sizeof(counts));
    for(int i=1;i<2*n;i++){
        for(int j=1;j<u;j++){
            if(lines[i].x1<=xs[j]&&xs[j]<lines[i].x2){
                counts[j] += lines[i].tag;
            }
        }
        int j=1;
        LL wid = 0;
        while(j<u){
            if(counts[j]==0) j++;
            else{
                int pre = j;
                while(j<u&&counts[j]>0) ++j;
                wid += xs[j]-xs[pre];
            }
        }
        // cout<<"---"<<wid<<' '<<lines[i].y<<"\n";
        ans += wid*(lines[i+1].y-lines[i].y);
    }
    printf("%lld\n",ans);
    return 0;
}
/*
4
1 10 15 8
1 6 14 3
2 9 5 1
11 15 13 5
*/